from cffi import FFI
import os
from PyCmpltrtok.common import get_dir_name_ext

xdir, xbase, xext = get_dir_name_ext(os.path.abspath(__file__))
xlib_dir = os.path.dirname(xdir)

ffibuilder = FFI()

ffibuilder.cdef("""
    int gcd(int x, int y);
    int in_mandel (double x0, double y0, int n); 
    int divide (int a, int b, int *remainder); 
    double avg (double *a, int n); 
    
    typedef struct Point {
        double x, y;
    } Point;
    
    double distance (Point *p1, Point *p2);
    double distance_my(Point p1, Point p2);
""")

ffibuilder.set_source(
    '_sample_cffi',
"""
    #include "sample.h"
""",
    libraries=[
        'sample',
    ],
    include_dirs=[
        xlib_dir,
    ],
    library_dirs=[
        xlib_dir,  
    ],
)

if __name__ == '__main__':
    ffibuilder.compile(verbose=True)
    